<template>
  <div>
    <div
      style="width: 100%; height: 96px; line-height: 96px; border-bottom: 4px solid #409eff;position: fixed; z-index: 1001; background-color: #fff; margin-top: 0px;"
    >
      <h1
        style="
        color: #409eff;
        display: inline;
        font-size: 48px;
        margin-left: 30px;
      "
      >机票预订系统</h1>
      <div style=" float: right; margin-right: 30px;">
        <el-button icon="el-icon-switch-button" circle @click="logOut"></el-button>
      </div>
    </div>
    <div style="width: 151px;float: left; position: fixed;top:100px;">
      <el-menu
        :default-active="activeIndex"
        :collapse="c"
        @select="handleSelect"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        style="width: 150px;min-height: 740px;"
      >
        <el-menu-item index="1">
          <i class="el-icon-s-custom"></i>员工管理
        </el-menu-item>
        <el-menu-item index="2">
          <i class="el-icon-s-promotion"></i>航班管理
        </el-menu-item>
        <el-menu-item index="3">
          <i class="el-icon-s-order"></i>订单管理
        </el-menu-item>
      </el-menu>
    </div>
    <div
      style=" width: 89%; margin-top: 110px; float: left; margin-left: 161px; margin-bottom: 10px; z-index: 1; "
    >
      <router-view></router-view>
    </div>
  </div>
</template>
  
  <script>
export default {
  data() {
    return {
      activeIndex: "1",
      c: false,
    };
  },
  mounted() {
    this.$router.push("/manageMain");
  },
  methods: {
    handleSelect(index) {
      this.activeIndex = index;
      if (index === "1") {
        this.$router.push("/manageMain");
      } else if (index === "2") {
        this.$router.push("/manageFlight");
      } else if (index === "3") {
        this.$router.push("/manageOrders");
      }
    },
    // 登出
    async logOut() {
      // 在这里提交表单
      await this.$axios
        .post("/api/emp/logout", "", {
          headers: { Authorization: "emp" },
        })
        .then((res) => {
          if (res.data.code === 1) {
            localStorage.removeItem("empToken");
            this.$router.push("/manageLogin");
            this.$message.success(res.data.msg);
          } else if (res.data.code === 0) {
            this.$message.error(res.data.msg);
          }
        })
        .catch((error) => {
          // 处理请求失败的错误
          this.$message.error("net ero");
        });
    },
  },
};
</script>
  
<style>
</style>